#!/usr/bin/env coffee

> ./STRIPE.coffee

# # error_on_requires_action: true
# # console.log mandate.customer_acceptance

paym = await STRIPE.paymentMethods.retrieve('pm_1OZV5qBS6OLyeF2QdyoUWMaH')

console.log paym
pay = await STRIPE.paymentIntents.create({
  amount: 10000_00 # 123.45欧元
  currency: 'eur'
  setup_future_usage: 'off_session'
  customer: paym.customer # 用户的customer id
  payment_method: paym.id # 用户的payment method id
  confirm: true
  # mandate_data:
  #   customer_acceptance: mandate.customer_acceptance
  automatic_payment_methods:
    enabled: true
    allow_redirects: 'never'
})

console.log pay

###

mandate = await STRIPE.mandates.retrieve 'mandate_1OZUuFBS6OLyeF2Q7C2X1m1h'

console.log mandate.customer_acceptance
paym = await STRIPE.paymentMethods.retrieve('pm_1OZUuFBS6OLyeF2QlEP4yJh0')

console.log paym
pay = await STRIPE.paymentIntents.create({
  amount: 10000_00 # 123.45欧元
  currency: 'eur'
  setup_future_usage: 'off_session'
  customer: paym.customer # 用户的customer id
  payment_method: paym.id # 用户的payment method id
  confirm: true
  mandate_data:
    customer_acceptance: mandate.customer_acceptance
  automatic_payment_methods:
    enabled: true
    allow_redirects: 'never'
})

console.log pay
###
# mandate_id =  'mandate_1OZV8UBS6OLyeF2QpQzmyGNn'
# #await STRIPE.mandates.retrieve mandate_id
#
#   # mandate: mandate_id
# # console.log mandate.customer_acceptance
# paym = await STRIPE.paymentMethods.retrieve('pm_1OZV8UBS6OLyeF2QakZvna3E')
#
# console.log paym
# pay = await STRIPE.paymentIntents.create({
#   amount: 10000_00 - 2# 123.45欧元
#   currency: 'eur'
#   customer: paym.customer # 用户的customer id
#   payment_method: paym.id # 用户的payment method id
#   confirm: true
#   automatic_payment_methods:
#     enabled: true
#     allow_redirects: 'never'
# })
# console.log pay
